#include <bits/stdc++.h>
#include <cstring>
using namespace std;

class Solution {
public:
    vector<vector<string>> groupAnagrams(vector<string>& strs) {
        vector<vector<string>> ans;
        int cnt[26];
        map<string, vector<string>> mp;
        for(auto& str: strs){
            memset(cnt, 0, sizeof(cnt));
            for(auto& chr: str){
                ++cnt[chr-'a'];
            }
            string cnt_str;
            for(int i=0; i<26; ++i) cnt_str += cnt[i];
            mp[cnt_str].emplace_back(str);
        }
        for(auto& it: mp){
            ans.emplace_back(it.second);
        }
        return ans;
    }
};

int main(){

}